/**
 * problem_032.cpp
 * Copyright (C) 2011 - xrose
 */
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int isDifdigit(int abc)
{
	int chek[9] = {0};
	int c;
	//cout<<"isDifdigit_abc = "<<abc<<endl;
	while(abc>0)
	{
		c = abc%10;
		if((c!=0)&&(chek[c-1]==0))
		{
			chek[c-1]=1;
			abc = abc/10;
		}else
		{
			return 0;
		}
	}
	return 1;
}
int isDif2digit(int abc, int def)
{
	int chek[9] = {0};
	int c;

	while(abc>0)
	{
		c = abc%10;
		if((c!=0)&&(chek[c-1]==0))
		{
			chek[c-1]=1;
			abc = abc/10;
		}else
		{
			return 0;
		}
	}

	while(def>0)
	{
		c = def%10;
		if((c!=0)&&(chek[c-1]==0))
		{
			chek[c-1]=1;
			def = def/10;
		}else
		{
			return 0;
		}
	}
	return 1;
}

int isDif3digit(int abc, int def, int ghi)
{
	int chek[9] = {0};
	int c;

	while(abc>0)
	{
		c = abc%10;
		if((c!=0)&&(chek[c-1]==0))
		{
//		    cout<<"abc_c= "<<c<<endl;
			chek[c-1]=1;
			abc = abc/10;
		}else
		{
			return 0;
		}
	}

	while(def>0)
	{
		c = def%10;
		if((c!=0)&&(chek[c-1]==0))
		{
			chek[c-1]=1;
			def = def/10;
		}else
		{
			return 0;
		}
	}
	while(ghi>0)
	{
		c = ghi%10;
		if((c!=0)&&(chek[c-1]==0))
		{
			chek[c-1]=1;
			ghi = ghi/10;
		}else
		{
			return 0;
		}
	}
	for(int i = 0; i<9; i++)
	{
		if(chek[i] == 0) return 0;
	}
	return 1;
}

int isPan(int abcdef)
{
	int abc = int(floor(sqrt(abcdef)));
	int def = 0;
	for(int i = 1; i<=abc; i++)
	{
		if((abcdef%i == 0))
		{
			def = abcdef/i;
//			cout<<abcdef<<"--"<<def<<endl;
			if(isDif3digit(i, def, abcdef))
			{
				return 1;
			}
		}
	}
	return 0;
}

int main (int argc, char const* argv[])
{
    int sum = 0;
    int cnt = 0;
	for(int i = 1; (i<99999); i++)
	{
	    if(isPan(i)==1)
	    {
//	        getchar();
	        sum+=i;
	    }
//	    cout<<"main_i = "<<i<<endl;
//        for(int j = 0; (j<9999); j++)
//        {
//            if(isDif3digit(i, j, i*j))
//            {
//                cout<<"COUNT: "<<++cnt<<endl;
//                cout<<"i = "<<i<<" j = "<<j<<" i*j = "<<i*j<<endl;
//                sum+=i*j;
//            }
//        }
	}
	cout<<sum<<endl;
	return 0;
}
